﻿using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace SXFramWork.Core
{
    public class MessageHub:Hub
    {
        private readonly ILoginInfo _loginInfo;
        private ICache _cache;
        public MessageHub(ILoginInfo loginInfo,ICache cache)
        {
            _cache = cache;
            _loginInfo = loginInfo;
        }
        public override async Task OnConnectedAsync()
        {
            //一个用户一个分组
            var uid = _cache.Get("uid");
            await Groups.AddToGroupAsync(Context.ConnectionId,uid);
            await base.OnConnectedAsync();
        }
    
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            await base.OnDisconnectedAsync(exception);
        }
    }
}
